﻿using gl_SMT.Model;
using Microsoft.Office.Interop.Excel;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace gl_SMT.View
{
    /// <summary>
    /// OPEventWindow.xaml 的交互逻辑
    /// </summary>
    public partial class OPEventWindow : System.Windows.Window
    {
        public OPEventWindow()
        {
            InitializeComponent();
            Loaded += OPEventWindow_Loaded;
        }

        DatabaseReadWrite database = new DatabaseReadWrite();
        public string Name { get; set; }
        public string sta_DateTime { get; set; }
        public string end_DateTime { get; set; }
        private void OPEventWindow_Loaded(object sender, RoutedEventArgs e)
        {
            gkg_EquipmentAlm();
        }

        private void gkg_EquipmentAlm()
        {
            string selectAlm = $"select * from gkg_Event where MachineName ='{Name}' " +
                $"AND CAST(Event_Day AS DATETIME) + CAST(Event_Time AS DATETIME) >= '{sta_DateTime}' " +
                $"AND CAST(Event_Day AS DATETIME) + CAST(Event_Time AS DATETIME) <= '{end_DateTime}'";
            System.Data.DataTable dt = database.SelectData(selectAlm);
            dataGrid_Aml.ItemsSource = dt.DefaultView;
        }
    }
}
